// /!*=========================表单验证==============================*!/
//验证用户名
document.querySelector(".username").onblur = checkUsername;
function  checkUsername(){
    //（1）获得用户名
    var username = document.querySelector(".username").value;
    console.log("用户名：" + username);

    //(2)用户名是否合格
    if(username == "" || username == null){// 是否为空
        //(3)消息提示
        document.querySelector(".username-msg").innerText = "用户名不能为空";
        return false;
    }else if( !/^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]+$/.test(username) ){ //
        document.querySelector(".username-msg").innerText = "用户名不正确";
        return false;
    }else{
        document.querySelector(".username-msg").innerText = "";
        return true;
    }

}
//验证密码
document.querySelector(".password").onblur = checkPassword;
function  checkPassword(){
    var password = document.querySelector(".password").value;
    if(password == "" || password == null){// 是否为空
        //(3)消息提示
        document.querySelector(".password-msg").innerText = "密码不能为空";
        return false;
    }else if( !/^[a-zA-Z0-9]\w{5,19}$/.test(password) ){
        document.querySelector(".password-msg").innerText = "密码不正确";
        return false;
    }else{
        document.querySelector(".password-msg").innerText = "";
        return true;
    }
}
//提交表单，验证
document.querySelector(".moco-btn").onclick= function (){

    if(checkUsername()  && checkPassword() ){

        // $("#signup-from").submit();
    };

}